;##################################
;命令：
;nasm -f elf64 day7_0vector_2shuffle_1ymm_0float.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Value in arr[0] is 1.111100.
;Value in arr[1] is 4.444400.
;Value in arr[2] is 2.234500.
;Value in arr[3] is 3.345600.
;Value in arr[4] is 5.555500.
;Value in arr[5] is 8.888800.
;Value in arr[6] is 6.678900.
;Value in arr[7] is 7.789100.
;##################################
extern printf

section .data
	msg: db `Value in arr[%d] is %f.\n`, 0
	arr0: dd 1.1111, 2.2222, 3.3333, 4.4444, 5.5555, 6.6666, 7.7777, 8.8888
	arr1: dd 1.1234, 2.2345, 3.3456, 4.4567, 5.5678, 6.6789, 7.7891, 8.8912

section .text
	global main

main:
	push rbp
	mov rbp, rsp

;##############################################
	vmovups ymm0, [arr0]
	vmovups ymm1, [arr1]
	;ymm可以装下
	;每4个float数作为一组进行shuffle
	;规则与xmm一致
	;前4组与后4组会进行相同的shuffle操作
	vshufps ymm0, ymm1, 10011100b
	vmovups [arr0], ymm0
;##############################################

	;打印
	mov ebx, 0
	jmp compare

execute:
	mov rdi, msg
	movsxd rsi, ebx
	cvtss2sd xmm0, dword [arr0 + 4 * ebx]
	movq rdx, xmm0
	call printf

	inc ebx

compare:
	cmp ebx, 8
	jl execute

	mov eax, 0
	leave
	ret
